package com.shy.base.vo;

import java.awt.Font;
import java.io.InputStream;
import java.net.Proxy;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;

import org.springframework.core.io.ClassPathResource;

/**
 * 全局常量信息
 * 
 * @author H2013788
 */
public class AppConstants {

	/** 默認日期格式化格式，用於页面显示或时间格式化轉換 */
	public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
	/** 默認时间格式化格式，用於页面显示或时间格式化轉換 */
	public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm";
	/** 秒级时间格式化格式，用於页面显示或时间格式化轉換 */
	public static final String DEFAULT_DATETIMESS_FORMAT =  "yyyy-MM-dd HH:mm:ss";
	/** 数据查询失败提示，一般用於通过ID查询對象失败提示 */
	public static final String GET_OBJECT_NULL = "GET_OBJECT_NULL";
	/** 客戶端提交参数有誤提示，用於前臺傳輸對象到後臺信息為空提示 */
	public static final String REQUEST_PARAM_NULL = "REQUEST_PARAM_NULL";
	/** 数据保存失败，一般為数据庫操作錯誤或底层代码錯誤 */
	public static final String SAVE_ERROR = "SAVE_ERROR";
	/** 保存成功提示，用於数据新增或修改 */
	public static final String SAVE_SUCCESS = "SAVE_SUCCESS";
	/** 数据刪除失败，一般為数据庫操作錯誤或底层代码錯誤 */
	public static final String DELETE_ERROR = "DELETE_ERROR";
	/** 操作成功提示，可用於通用操作描述 */
	public static final String OPERATE_SUCCESS = "OPERATE_SUCCESS";
	/** 操作失败提示 */
	public static final String OPERATE_ERROR = "OPERATE_ERROR";
	/** 数据違反唯一性標識 */
	public static final String DUPLICATE_DATA = "DUPLICATE_DATA";
	/** 頂级菜单链接 */
	public static final String DEFAULT_MENU_URL = "javascript:void(0);";
	/**登錄页面路径*/
    public static final String TIMEOUT_URL = "TIMEOUT_URL";
    
    /** 登錄时用户名字段*/
    public final static String LOGIN_USER_PARAM = "username";
    
    /** 操作日志详情，需要屏蔽部分字段 */
    public final static String[] EXCLUDE_PARAMS_LOG = new String[] {"password"};
    
    /**
	 * 未使用字段过濾
	 */
	public static String UNUSED_FIELDS = "unusedFields";
	
	/**
	 * like查询字段过濾
	 */
	public static String LIKE_TYPES = "likeFields";

	/** 参数存储map對象 */
	public static Map<String, String> configMap = new HashMap<String, String>();
	
	/** 上传目录格式 */
    public static final String UPLOAD_BASE_PATH = "/uploads";
	
	/** 上传目录格式 */
	public static final String UPLOAD_PATH_FORMAT = "/{yyyy}/{mm}/{dd}/{time}{rand:6}";
	
    /** 允許上传图片格式 */
    public static final String[] UPLOAD_ALLOWED_TYPE_IMG = new String[] {".png", ".jpg", ".jpeg", ".gif", ".bmp"};
    
    /** 允許添加水印的图片格式 */
    public static final String[] WATERMARKER_ALLOWED_TYPE_IMG = new String[] {".png", ".jpg", ".jpeg"};
	
	/** 緩存栏目key */
	public static final String REDIS_TYPE_LIST = "common:typeList";
    
    /** 緩存站点key */
	public static final String REDIS_SITE_LIST = "common:siteList";
	
	/** 緩存栏目key */
	public static final String REDIS_TYPE_MAP = "common:typeMap";
    
    /** 緩存站点key */
	public static final String REDIS_SITE_MAP = "common:siteMap";
	
	/** 緩存栏目key */
	public static final String REDIS_TYPE_TREE = "common:typeTree";
	
	/** 緩存栏目信息 */
    public static final String REDIS_TYPE_INFO = "common:type:";
    
    /** 緩存站点信息 */
    public static final String REDIS_SITE_INFO = "common:site:";
    
    /** 生成文章进度 */
    public static final String REDIS_MAKE_ARTICLE_PROCESS = "common:makeProcess";
    
    /** 生成栏目进度 */
    public static final String REDIS_MAKE_TYPE_PROCESS = "common:makeTypeProcess";
    
    /** 生成图书进度 */
    public static final String REDIS_MAKE_BOOK_PROCESS = "common:makeBookProcess";
    
    /** 生成图书列表进度 */
    public static final String REDIS_MAKE_BOOK_LIST_PROCESS = "common:makeBookListProcess";
    
    /** 生成专题进度 */
    public static final String REDIS_MAKE_TOPIC_PROCESS = "common:makeTopicProcess";
    
    
    /** 生成文章进度 */
    public static final String REDIS_MAKE_INFO_PROCESS = "common:makeInfoProcess";
    
    /** 生成栏目进度 */
    public static final String REDIS_MAKE_INFOLIST_PROCESS = "common:makeInfoListProcess";
    
    
    /** 访问信息 */
    public static final String REDIS_VISIT = "visit:list";
	
	/** 用户权限站点key */
	public static final String REDIS_USER_SITE = "user:site";
	
	/** 文章信息key */
    public static final String REDIS_ARTICLE_INFO = "article:info";
    
    /** 文章列表信息key */
    public static final String REDIS_ARTICLE_LIST = "article:list:";
    
    /** 快讯列表信息key */
    public static final String REDIS_INFO_LIST = "info:list:";
    
    /** 待执行任务信息 */
    public static final String REDIS_TASK_LIST = "task:article:";
    
    /** 图书列表信息key */
    public static final String REDIS_BOOK_LIST = "book:list:";
    
    /** 章節列表信息key */
    public static final String REDIS_CHAPTER_LIST = "chapter:list:";
    
    /** 友鏈列表信息key */
    public static final String REDIS_LINK_LIST = "link:list:";
    
    /** 栏目列表信息key */
    public static final String REDIS_MENU_LIST = "menu:list:";
    
    /** 专题列表信息key */
    public static final String REDIS_TOPIC_LIST = "topic:list:";
    
    /** 临时信息key */
    public static final String REDIS_TEMP_INFO = "temp:";
    
    /** 緩存有效期 24h*/
    public static final long REDIS_24H_EXPIRE = 24 * 60 * 60;
    
    /** 緩存有效期2h */
    public static final long REDIS_2H_EXPIRE = 2 * 60 * 60;
    
    /** 緩存有效期10m */
    public static final long REDIS_10M_EXPIRE = 10 * 60;
    
    /** 緩存有效期5m */
    public static final long REDIS_5M_EXPIRE = 5 * 60;
    
    /** 网络代理 */
    //public static Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.195.217.221", 8089));
    public static Proxy proxy = null;
    
    /** http请求默认超时时间 */
    public static final int HTTP_TIMEOUT = 10000;
    
    /** 自动发布数据设置flag */
    public static String[] flags = new String[] {"h", "c", "a", "t", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "bx"};

    public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
    
    /** 图片质量 */
    public static final String IMG_QUALITY = "IMG_QUALITY";
    
    /** 开启图片水印 */
    public static final String IMG_WATERMARKER = "IMG_WATERMARKER";
    
    /** 默认水印文字 */
    public static final String DEFAULT_WATERMARKER = "DEFAULT_WATERMARKER";
    
    /** 图片前缀 */
    public static final String IMG_PREFIX = "IMG_PREFIX";
    
    /** 图片自动alt */
    public static final String IMG_AUTO_ALT = "IMG_AUTO_ALT";
    
    
    public static String[] userAgentList = new String[] {
            "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)",
            "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)",
            "Mozilla/5.0+(compatible;+Yahoo!+Slurp;+http://help.yahoo.com/help/us/ysearch/slurp)",
            "Mozilla/5.0 (compatible; YoudaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; )"
    };
    
    public static final String[] SUFFIX_OLD = new String[] {
			"完整文集阅读","全集小说推荐","精选小说推荐","畅销小说推荐","最新热门小说","叫什么名字","是什么名字",
			"高质量小说","完整阅读","全文阅读","全文完结","精品小说","精品阅读","精选小说","全集小说","全本阅读",
			"全章阅读","全部目录","完整文本","优秀文集","长篇小说","热门小说","畅销巨著","畅销巨作","文笔细腻",
			"精彩章节","强推现言","独家首发","独家完结","独家整理","六月新书","完结分享","热门求书","多人收藏",
			"的叫什么","全文版","完整版","免费看","叫什么","无弹窗","未删减","大结局","书名是","已完结","校园文",
			"无广告","现言文","是什么","男主叫","完结版","无删减","无错版","第4章","第14章","第10章","第6章",
			"完整","全文","阅读","抖音","热文","盘点","小说","主角","最新","试读","txt","推荐","爆款","渣文",
			"章节","全本","知乎","快手","热门","全集","女频","强推","原名","整理","求书","虐文","高赞","作者","目录"
	};
    
    public static final String[] SUFFIX_NEW = new String[] {
    		"精选作品之一","纯净无弹窗版","经典荡气回肠","一口气读完","完整版阅读","高质量好文","评价五颗星","老书虫推荐",
    		"推荐必读","必读爽文","完结爽文","高分完本","高分言情","宝藏美文","好文分享","精彩分享","每日分享","爆款宝藏",
    		"畅销巨著","在线品鉴","最新章节","免费品鉴","免费赏析","在线赏析","全文赏析","抖音新书","快手新书","热门榜单",
    		"新上热文","文章简述","完结全本","高分佳作","优质全章","精品选集","言情作品","极佳剧情","精彩剧情","小编推荐",
    		"新鲜出炉","全面完结","现已上架","内容精选","爱恨纠葛","热血十足","异常火爆","一致好评","火爆情节","人物讨喜",
    		"情感纠葛","看点十足","灵魂人物","创作编写","创作出彩","潜心更新","倾心编著","精心编著","精心打造","精编之作",
    		"独家出品","宝藏文","笔趣阁","无删版","必读文","高口碑","实力派","爽文"
	};
    
    
    /** 水印字体 */
    public static Font WATER_MARKER_FONT = null;
    
    static {
        try {
            // 初始化字体
            InputStream fontInput = new ClassPathResource("MSYH.TTC").getInputStream();
            WATER_MARKER_FONT = Font.createFont(Font.TRUETYPE_FONT, fontInput);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
